#ifndef CHATLISTITEM_H
#define CHATLISTITEM_H

#include <QWidget>
#include "listitembase.h"
#include "userdata.h"

namespace Ui {
class ChatListItem;
}

class ChatListItem : public QWidget
{
    Q_OBJECT

public:
    explicit ChatListItem(QWidget *parent = nullptr);
    ~ChatListItem();

    //用户数据
    int user_id;
    QString user_msgId;
    QString user_name;
    QString user_email;
    QString user_avatar;
    double user_score;
    int user_newMsgNums = 0;

    QSize sizeHint() const override;

    void SetInfo(int id,QString msgId,QString name,QString email,QString avatar);
    void SetInfo(QString msg,int newMsgNums,double nowTime,double score);

    void setAvatar(QString fileName);
    void setTime(double nowTime);
    void setMsgAndTime(QString msg,double nowTime);//设置聊天信息

    void ShowRedPoint(int newMsgNums);//新消息数量显示
    void reSetNewMsgNums();//重置新消息为0

    QStringList GetInfo();//返回好友信息给聊天界面
    //score为redis储存消息的序号
    double getScore();
    QString getMsgId();
    int getNewMsgNums();//获取新消息数量
    QString getAvatar();
private:
    Ui::ChatListItem *ui;
//    std::shared_ptr<UserInfo> _info;
    void setMsg(QString msg);
};

#endif // CHATLISTITEM_H
